#include <board.h>
#include <lcd/lcdd.h>
#include <lcd/draw.h>
#include <pit/pitd.h>

static unsigned char lcd [BOARD_LCD_WIDTH * BOARD_LCD_HEIGHT * 3];

#define PERIOD ((unsigned int) 1e3) // PERIOD * microsseconds

static unsigned int sec = 0;

void cozz (void) {
    if (++sec / PERIOD != 0) {
        LCDD_DrawFormattedString(lcd, 10, 10, COLOR_BLACK, "%d", (sec - 1) / PERIOD);
        LCDD_DrawFormattedString(lcd, 10, 10, COLOR_GREEN, "%d", sec / PERIOD);
    }
}

int main(void)
{
    LCDD_Fill(lcd, COLOR_BLACK);
    LCDD_Initialize();
    LCDD_DisplayBuffer(lcd);

    PITD_Configure(cozz, PERIOD, 1);
    LCDD_DrawFormattedString(lcd, 10, 10, COLOR_GREEN, "%d", sec);
    PITD_Start();

    while (1);

    return 0;
}
